package com.test.jdk.streamApi;

import java.util.Comparator;
import java.util.Optional;
import java.util.stream.Stream;

public class StreamTestMaxAndMin {
    public static void main(String[] args) {

        //获取最大值和最小值，那么可以使用max和min方法
        Optional<Integer> max = Stream.of("1", "3", "3", "4", "5", "1", "7")
                .map(Integer::parseInt)
                .max((o1, o2) -> o1 - o2);
        System.out.println(max.get());
        Optional<Integer> min = Stream.of("1", "3", "3", "4", "5", "1", "7")
                .map(Integer::parseInt)
                .min((o1, o2) -> o1 - o2);
        System.out.println(min.get());

    }


}
